package com.log.james.mapper;

import com.log.james.entity.WebLog;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Mapper
public interface WebLogDao {
    @Select("select * from weblogstatistics where starttime >= #{st} and endtime <= #{et}")
    List<WebLog> findWebLogByTime(@Param("st")Date st,@Param("et")Date et);

    /**
     * 获取这个时间段内各个状态码的情况
     * @param st
     * @param et
     * @return
     */
    @Select("SELECT reactNum ,sum(times) as num FROM weblogstatistics WHERE starttime >= #{st} and endtime <= #{et} GROUP BY reactnum ORDER BY num DESC")
    List<Map<String,Object>> findReactNumByTime(@Param("st")Date st,@Param("et")Date et);

    /**
     * 获取这个时间段内各个源城市的次数
     * @param st
     * @param et
     * @return
     */
    @Select("SELECT address,count(id) as num FROM weblogstatistics WHERE starttime >= #{st} and endtime <= #{et} GROUP BY address ORDER BY num DESC")
    List<Map<String,Object>> findCityNumByTime(@Param("st")Date st,@Param("et")Date et);
}
